import fetch from 'utils/fetch';

//新增代理商
export function createAgent(data) {
  return fetch({
    url: 'api/admin/distributor/create',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}

//代理商查询
export function agentAll(data) {
  return fetch({
    url: 'api/admin/distributor/screenSelectDistributor',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}

// 审核代理商详情
export function auditAgentDetails(id) {
  return fetch({
    url: 'api/admin/distributor/getDistributorIdFindDistributor/'  + id,
    method: 'get',
    headers: {'Content-type': 'application/json;charset=UTF-8'}
  });
}

//代理商详情
export function agentDetails(id) {
  return fetch({
    url: 'api/admin/distributor/getDistributorIdFind/'  + id + '/s',
    method: 'get',
    headers: {'Content-type': 'application/json;charset=UTF-8'}
  });
}

//修改代理商
export function modifyAgent(data) {
  return fetch({
    url: 'api/admin/distributor/update',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}

//审核代理商
export function updateStateAgent(data) {
  return fetch({
    url: 'api/admin/distributor/updateState' ,
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}

//查询业务员
export function salesmanList(data) {
  return fetch({
    url: 'api/admin/salesman/screenSelectSalesman',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}

//修改代理商查询业务员
export function salesmanAll(data) {
  return fetch({
    url: 'api/admin/salesman/getFindDistributorSalesman',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}

//新增业务员
export function salesmanAdd(data) {
  return fetch({
    url: 'api/admin/salesman/insertSelective',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}

//查询上级代理
export function querySuperiorAgent(data) {
  return fetch({
    url: 'api/admin/distributor/getcompanyIdFindDistributor',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}


//验证业务员编号
export function validateSalesmanNum(salesmanNumber,BD_id) {
  return fetch({
    url: 'api/admin/salesman/getSalesmanNumberFindSalesman/' + salesmanNumber + '/' + BD_id + '/s',
    method: 'get',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
  });
}

//修改业务员信息
export function modifySalesman(data) {
  return fetch({
    url: 'api/admin/salesman/updateSalesman',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}

//删除审核未通过代理商
export function delAgent(id) {
  return fetch({
    url: 'api/admin/distributor/deleteDistributor/' + id + '/s',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
  });
}

//新增验证代理商名称
export function validateBDName(BD_name) {
  return fetch({
    url: 'api/admin/distributor/verificationDistributorName/s',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data:{
      name:BD_name
    }
  });
}

//修改验证代理商名称
export function validateBDNameModify(BD_name,distributorId) {
  return fetch({
    url: 'api/admin/distributor/verificationDistributorName/s',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data:{
      name:BD_name,
      id:distributorId
    }
  });
}

//新增验证代理商电话
export function validateBDPhone(BD_phone) {
  return fetch({
    url: 'api/admin/distributor/verificationPhone/' + BD_phone + '/s',
    method: 'get',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
  });
}

//修改验证代理商电话
export function validateBDPhoneModify(BD_phone,distributorId) {
  return fetch({
    url: 'api/admin/distributor/verificationPhone/' + BD_phone + '/' + distributorId  + '/s',
    method: 'get',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
  });
}


//新增修改验证代理商邮箱
export function validateBDEamil(BD_Eamil) {
  return fetch({
    url: 'api/admin/distributor/verificationEmail/' + BD_Eamil + '/s',
    method: 'get',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
  });
}

//修改修改验证代理商邮箱
export function validateBDEamilModify(BD_Eamil,distributorId) {
  return fetch({
    url: 'api/admin/distributor/verificationEmail/' + BD_Eamil + '/' + distributorId  + '/s',
    method: 'get',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
  });
}

//查询代理商等级
export function queryBD_grade(distributorId) {
  return fetch({
    url: 'api/admin/distributor/findDistributorGrade/' + distributorId  + '/s',
    method: 'get',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
  });
}

//2.5应急需求改动
export function queryAgentAll(data) {
  return fetch({
    url: 'api/admin/distributor/selectAllDistributor',
    method: 'post',
    headers: {'Content-type': 'application/json;charset=UTF-8'},
    data
  });
}